<template>
  <ul class="wrap products">
    <li
      v-for="item in productdata"
      :key="item.id"
      @click="gotoDetailsFn(item.id)"
    >
      <img
        src="@/assets/images/section_hot.png"
        class="labelimg"
        alt=""
        v-if="item.isHotSale"
      />
      <img
        src="@/assets/images/section_new.png"
        class="labelimg"
        alt=""
        v-if="item.isLatest"
      />
      <img :src="imgBaseUrl + item.coverImg" class="productimg" alt="" />
      <p class="name">{{ item.name }}</p>
      <p class="integral">{{ item.coin }}积分</p>
      <div class="btn">立即兑换</div>
    </li>
  </ul>
</template>

<script>
export default {
  props: ["productdata"],
  methods: {
    // 根据id跳转到详情页
    gotoDetailsFn(id) {
    //   console.log("id:" + id);
      this.$router.push(`/details?id=${id}`);
    },
  },
};
</script>

<style lang="less" scoped>
.products {
  display: flex;
  // justify-content: space-between;
  flex-wrap: wrap;
  li {
    height: 412px;
    width: 285px;
    background: #ffffff;
    text-align: center;
    font-size: 18px;
    font-family: SourceHanSansSC;
    margin-bottom: 20px;
    transition: all 0.5s;
    position: relative;
    left: 0;
    top: 0;
    margin-right: 20px;
    box-sizing: border-box;

    // 所有4的倍数
    &:nth-of-type(4n) {
      margin-right: 0;
    }

    &:hover {
      top: -10px;
    }

    .labelimg {
      position: absolute;
      left: 0;
      top: 0;
    }

    .productimg {
      display: block;
      margin: 0 auto;
      height: 250px;
    }
    .name {
      margin-top: 22px;
      font-weight: 300;
      color: #333333;
    }
    .integral {
      margin-top: 16px;
      margin-bottom: 38px;
      font-weight: bold;
      color: #fd604d;
    }
    .btn {
      width: 100px;
      height: 36px;
      line-height: 36px;
      border: 1px solid #0a328e;
      margin: 0 auto;
      font-weight: 300;
      color: #0a328e;
      cursor: pointer;

      &:hover {
        color: #ffffff;
        background-color: #0a328e;
      }
    }
  }
}
</style>